<!--
 * @Author: panghu chenjh@datamargin.com
 * @Date: 2024-04-18 13:56:34
 * @LastEditors: panghu chenjh@datamargin.com
 * @LastEditTime: 2024-05-04 14:47:17
 * @FilePath: \zheye\src\components\Loader.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <Teleport to="#back">
    <div class="d-flex justify-content-center align-items-center h-100 loading-container" :style="{backgroundColor: background || ''}">
      <div class="loading-content">
        <div class="spinner-border text-primary" role="status">
          <!-- <span class="sr-only">{{ text || 'Loading...' }}</span> -->
        </div>
        <p v-if="text" class="text-primary small">{{ text }}</p>
      </div>
    </div>
  </Teleport>
</template>

<script lang="ts">
import { defineComponent, onUnmounted } from 'vue'
import useDomCreate from '@/hooks/useDomCreate'
export default defineComponent({
  name: 'LoaderComp',
  props: {
    text: {
      type: String,
      default: 'Loading...'
    },
    background: {
      type: String
    }
  },
  setup () {
    useDomCreate('back')
    return {}
  }
})
</script>

<style scoped>
.loading-container{
  background: rgba(255, 255, 255, .5);
  z-index: 100;
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}
.loading-container {
  text-align: center;
}
</style>
